const base = window.ROOTPATH || '';

const settings = {
  title: '四川省农业信贷智能担保综合管理平台',
  base,
  range: '~',
  prefix: `${base}/api/`,
  pageNumber: 'page',
  pageSize: 'size',
  search: 'con', // 通用检索字段
  valid: 'name', // 通用校验字段
  code: 200,
  home: '/system/user'
};

export const pagination = {
  pageSize: 20,
  pageNumber: 1,
};

export const getPagination = oldPagination => {
  const newPagination = {};
  const { pageNumber, pageSize } = oldPagination;
  if (pageNumber != null) {
    newPagination[settings.pageNumber] = pageNumber;
  }
  if (pageSize != null) {
    newPagination[settings.pageSize] = pageSize;
  }
  return newPagination;
};

export default {
  ...settings,
  pagination: getPagination(pagination),
};
